package com.example.appforpatient.fragment;
import java.util.ArrayList;
import java.util.HashMap;

import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;

import com.example.appforpatient.R;
import com.example.appforpatient.adapter.ServiceConnector;
import com.example.appforpatient.adapter.ServiceConnector.PatientInfo;



public class FragmentSchedule extends Fragment {
 
    public static Fragment newInstance(Context context) {
    	FragmentSchedule f = new FragmentSchedule();
 
        return f;
    }
 
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
        ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_schedule, null);
        ListView list = (ListView)root.findViewById(R.id.lvSchedule);
        
        ArrayList<HashMap<String, String>> mylist = ServiceConnector
				.getSingleton().getPatientSchedule().printAdapter();
        
        SimpleAdapter mSchedule = new SimpleAdapter(getActivity()
				.getApplicationContext(), mylist,
				R.layout.item_listview_schedule, new String[] { "PatientID",
						"PatientName", "PatientDate", "PatientTime",
						"PatientService", "PatientAddress" }, new int[] {
						R.id.tv_sche_patientID, R.id.tv_sche_patientName,
						R.id.tv_sche_patientDate, R.id.tv_sche_patientTime,
						R.id.tv_sche_patientService,
						R.id.tv_sche_patientAddress });
		
		list.setAdapter(mSchedule);
        
        PatientInfo pi = ServiceConnector.getSingleton().getPatientInfo();
        
        TextView tv_sche_health = (TextView) root
				.findViewById(R.id.tv_sche_health);
		tv_sche_health.setText(pi.health);
		
		TextView tv_sche_expired = (TextView) root
				.findViewById(R.id.tv_sche_expired);
		tv_sche_expired.setText(pi.expired);
        
        return root;
    }
 
    
}